''' #@误差图
    #@功能：
        画误差曲线，也可以用于画置信区间/标准差/方差
    #@参数：
        plt.errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None, capsize=None, capthick=None )
        x：横坐标的值
        y：纵坐标的值
        yerr：y值的误差范围
        xerr：x值的误差范围
        fmt：数据点的标记样式以及相互之间连接线样式
        ecolor: 误差棒的线条颜色
        elinewidth: 误差棒的线条粗细
        capsize: 误差棒边界横杠的大小
        capthick: 误差棒边界横杠的厚度
        ms: 数据点的大小
        mfc: 数据点的颜色
        mec: 数据点边缘的颜色
    '''


from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
import matplotlib



#// 2. 读数据
#! 修改项
# path = r"C:\Users\lainiao\Desktop\a.xlsx"
# data = pd.read_excel(path)
# print(data)





def 房地产():
    #// 1. 中文显示
    # plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
    #// 2. 标签
    # plt.title("房地产估值数据集实验")
    # plt.xlabel("横轴标签")
    plt.ylabel("$\\alpha$")
    #// 3. 数据
    x=["house age", "distance to station", "number of stores", "latitude","longitude"]
    y1=[0.238807585,0.045259952,0.261076489,0.407870515,1.546985459]
    yerr1=[0.195371595,0.030682696,0.094640491,0.171151015,0.293943465]
    y2=[0.488545603,0.333439413,0.563816588,0.525397125,0.588801271]
    yerr2=[0.042236216,0.015855403,0.058202853,0.051651295,0.059255775]
    #// 4. 绘制
    plt.errorbar(x,y1,yerr=yerr1,fmt='o-',elinewidth=2,capsize=4,label='$Q_1$') #ecolor='r',color='b',
    plt.errorbar(x,y2,yerr=yerr2,fmt='o-',elinewidth=2,capsize=4,label='$Q_3$') #ecolor='r',color='b',
    plt.legend()
    plt.xticks(rotation=10,)
    plt.show()


def AUTO_MPG():
    #// 1. 中文显示
    # plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
    #// 2. 标签
    # plt.title("AUTOMPG数据集实验")
    # plt.xlabel("横轴标签")
    plt.ylabel("$\\alpha$")
    #// 3. 数据
    x=["气缸数","排量","马力","重量","加速度","出厂年份","产地"]
    x=["Cylinders","Displacement","Horsepower","Weight","Acceleration","Model Year","Origin"]
    y1=[0.42214346,0.333990754,0.082420179,0.096405055,1.874366122,0.255297172,0.435377257]
    yerr1=[0.505431765,0.657958924,0.070409138,0.042883075,0.867026515,0.087456559,0.292952986]
    y2=[0.525594913,0.503083057,0.438814887,0.347890639,0.598313997,0.476870463,0.609432044]
    yerr2=[0.03766177,0.045075211,0.036770949,0.014120768,0.032589877,0.019773132,0.037218716]
    #// 4. 绘制
    plt.errorbar(x,y1,yerr=yerr1,fmt='o-',elinewidth=2,capsize=4,label='$Q_1$') #ecolor='r',color='b',
    plt.errorbar(x,y2,yerr=yerr2,fmt='o-',elinewidth=2,capsize=4,label='$Q_3$') #ecolor='r',color='b',
    plt.legend()
    plt.xticks(rotation=10,)
    plt.show()



def 人工数据():
    #// 1. 中文显示
    # plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
    #// 2. 标签
    # plt.title("标题")
    # plt.xlabel("横轴标签")
    plt.ylabel("$\\alpha$")
    #// 3. 数据
    x=["$x_1$","$x_2$","$x_3$","$x_4$"]
    y1=[1.593186143,0.372668671,0.026571935,0.007573251]
    yerr1=[0.797564747,0.758924599,0.036048599,0.009128515]
    y2=[0.614935942,0.601785956,0.465811596,0.317466506]
    yerr2=[0.040178806,0.036378464,0.019017587,0.007496487]
    #// 4. 绘制
    plt.errorbar(x,y1,yerr=yerr1,fmt='o-',elinewidth=2,capsize=4,label='$Q_1$') #ecolor='r',color='b',
    plt.errorbar(x,y2,yerr=yerr2,fmt='o-',elinewidth=2,capsize=4,label='$Q_3$') #ecolor='r',color='b',
    plt.legend()
    plt.show()




def 媒体融合模式():
    #// 1. 中文显示
    plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
    #// 2. 标签
    # plt.title("标题")
    # plt.xlabel("横轴标签")
    plt.ylabel("$\\alpha$")
    #// 3. 数据
    x=['传统媒体','新媒体','自媒体','政务媒体','企业媒体','商务主体','公共服务']
    # x=["$x_1$","$x_2$","$x_3$","$x_4$"]   
    y1=[0.515933896,0.555158674,0.457740209,0.442352958,0.614332401,0.551723318,0.362758544]
    yerr1=[0.062458239,0.041093579,0.040753485,0.077360486,0.059262618,0.044870177,0.027225726]
    yerr1=[0.062458239,0.041093579,0.040753485,0.077360486,0.059262618,0.044870177,0.027225726]
    # y2=[0.614935942,0.601785956,0.465811596,0.317466506]
    # yerr2=[0.040178806,0.036378464,0.019017587,0.007496487]
    #// 4. 绘制
    plt.errorbar(x,y1,yerr=yerr1,fmt='o-',elinewidth=2,capsize=4,label='$Q_1$') #ecolor='r',color='b',
    # plt.errorbar(x,y2,yerr=yerr2,fmt='o-',elinewidth=2,capsize=4,label='$Q_3$') #ecolor='r',color='b',
    # plt.legend()
    plt.show()






# 人工数据()
# 房地产()
# AUTO_MPG()
媒体融合模式()